package com.athuiju.fenxiaoback.service.impl;

import com.athuiju.fenxiaoback.entity.HjVisit;
import com.athuiju.fenxiaoback.entity.HjWorkExperience;
import com.athuiju.fenxiaoback.entity.vo.VisitWorkExVo;
import com.athuiju.fenxiaoback.mapper.HjVisitMapper;
import com.athuiju.fenxiaoback.mapper.HjWorkExperienceMapper;
import com.athuiju.fenxiaoback.service.HjVisitService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zs
 * @since 2021-10-11
 */
@Service
public class HjVisitServiceImpl extends ServiceImpl<HjVisitMapper, HjVisit> implements HjVisitService {

    @Autowired
    HjVisitMapper hjVisitMapper;

    @Autowired
    HjWorkExperienceMapper workExperienceMapper;

    @Override
    public boolean saveVisit(VisitWorkExVo visitWorkExVo) {

        HjVisit visit=new HjVisit();
        BeanUtils.copyProperties(visitWorkExVo,visit);

        HjWorkExperience workExperience=new HjWorkExperience();
        BeanUtils.copyProperties(visitWorkExVo,workExperience);

        System.out.println("visit--------------");
        System.out.println(visit);
        int visitinsert = hjVisitMapper.insert(visit);


        System.out.println("workExperience--------------");
        System.out.println(workExperience);
        workExperience.setVisitId(visit.getId().intValue());
        int workinsert = workExperienceMapper.insert(workExperience);

        if (visitinsert>0 && workinsert>0){
            return true;
        }
        return false;
    }
}
